package com.ipt.frm.pw;

import java.io.IOException;
import java.util.ArrayList;








import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;







import org.apache.log4j.PropertyConfigurator;

import com.ipartek.formacion.DAO.DAOFactory;
import com.ipartek.formacion.DAO.MySqlAlumnoDAO;
import com.ipartek.formacion.DAO.MySqlDAOFactory;
import com.ipartek.formacion.bean.Alumno;


/**
 * Servlet implementation class PrimerServlet
 */
public class servletRanking extends ServletMaestro {
      
	private static final long serialVersionUID = -7222970621860173660L;
	private static MySqlDAOFactory factoria=null;
	private static MySqlAlumnoDAO  alumnoDAO= null;
	private static ArrayList<Alumno> listaAlumnos = new ArrayList<Alumno>();
	/**
     * @see HttpServlet#HttpServlet()
     */
    public servletRanking() {
        super();
   
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		factoria= new MySqlDAOFactory();
		alumnoDAO = factoria.getInterfaceAlumnoDAO();
		try {
			//Cargamos la listaAlumnos con los datos de la Base de Datos
			listaAlumnos = alumnoDAO.getRankingGlobal();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		//Cargamos el ArrayList en el request
		request.setAttribute("tblAlumnos", listaAlumnos);
		 //Dispatcher
		request.setAttribute("title","Ranking de Usuarios");
		RequestDispatcher dispatcher = request.getRequestDispatcher("/ranking.jsp");
		dispatcher.forward(request, response);
       
      
        
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
